Lesson 5 - Translate the code!

Gap-fill exercise

Fill in all the gaps, then press "Check" to check your answers. Use the "Hint" button to get a free letter if an answer is giving you trouble. You can also click on the "[?]" button to get a clue. Note that you will lose points if you ask for hints or clues!
guess = input("Enter a number ")
secret = 21
if guess > secret:
print "guess is too big"
elif guess < secret:
print "guess is too small"
else:
print "Well done you guessed correctly!"

# see if they were close or not!
diff = guess - secret
# diff could be negative!
if diff < 0:
diff = diff * -1
# if your within 10 then let the user know!
if diff < 10:
print "Your really close. Well done!"

Translation

Get a value from the user and assign it to the variable guess. the value 21 to secret. Test to see if the guess is than secret. If it is then "guess is too big". if it is than secret then print "guess is too small". Otherwise print out "Well done you guessed correctly!"

secret from guess and the result into variable diff. Test to see if diff is than 0, if it is that multiply diff by -1. Then test to see if is smaller than 10. If it is then out "your really close. Well done!"